class Person {
  name: string
  age: number
  // 入参也必须写类型
  constructor(name: string, age: number) {
    this.name = name
    this.age = age
  }
  speak() {
    console.log(`${this.name}今年${this.age}岁`)
  }
}


class Student extends Person {
  grade: string
  constructor(name: string, age: number, grade: string) {
    super(name, age)
    this.grade = grade
  }
  // override :复写父类方法，防止写错
  override speak() {
    console.log(`${this.name}今年${this.age}岁,现在${this.grade}`)
  }
}

const s1 = new Student("小米",12,"高三")
console.log(s1)
s1.speak()
